<?php
include("../inc/db_connect.php");
include("../inc/functions.php");

$vypis = 0;
$nac_s = "SELECT SUM(kolko) as kolko FROM falkstrava WHERE zid = '".$_POST['zid']."' AND mesiac='".$_POST['mesiac']."' AND rok='".$_POST['rok']."'";
$nac_q = MySQL_Query ($nac_s);
$nac = MySQL_Fetch_Array ($nac_q);
$vypis += $nac['kolko'];

$kolko = $_POST['kolko'] - $vypis;

$uloz_i = "INSERT INTO falkstrava (id, zid, date, mesiac, rok, kolko) VALUES (NULL,'".$_POST['zid']."', '9999999999', '".$_POST['mesiac']."', '".$_POST['rok']."', '".$kolko."')";
$uloz_q = MySQL_Query ($uloz_i);
?>
